import requests from './request';

//返回的是promise对象
export const reqTalkList = ()=>requests({url:'/talks',method:'GET'});
export const reqUserList = ()=>requests({url:'/users',method:'GET'});
export const reqStudyList = ()=>requests({url:'/studys',method:'GET'});




//返回当前时间
function setNowTime(){
    const year = new Date().getFullYear();
    const month = new Date().getMonth()+1;
    const day = new Date().getDate();
    const hours = new Date().getHours();
    const minutes = new Date().getMinutes();
    return year+'.'+month+'.'+day+'  '+
            hours+':'+minutes;
};

//添加一个新的说说
export let addTalkListAxios = function(newList){
    requests({
        url:'/talks',
        method:'POST',
        data: {
            msg: newList,
            date: setNowTime()
        }
    });
}

// export let addStudyListAxios = function(newList){
//     requests({
//         url:`'/study/${newList.name}'`,
//         method:'POST',
//         data: {
//             child:[
//                 {
//                     title: newList.title,
//                     msg: newList.msg
//                 }
//             ]
//         }
//     });
// }

